package seata.account.service;

import io.seata.core.context.RootContext;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class AccountService {
    final JdbcTemplate jdbcTemplate;

    public void reduce(String userId, int money) {
        log.info("Account Service ... xid: " + RootContext.getXID());
        jdbcTemplate.update("update account_tbl set money = money - ? where user_id = ?", money, userId);
    }
}